package com.zy.aop.excerse1;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by zy on 2015/10/25.
 */
public class LogInvocationHandler implements InvocationHandler {
    private Object target;

    public LogInvocationHandler(Object target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object rev = method.invoke(target, args);
        if (method.getName().equals("doSomeThing2")) {
            System.out.println("打印日志");
        }
        return rev;
    }
}
